var x = 10,
    y = 20;

$(function () {
    $('#qwe2').mouseover(function (e) {
        if (e.target.matches('img')) {
            let par = e.target;
            let param = e.target.parentElement.search.substr(12);
            $.ajax({
                type: 'GET',
                url : 'http://localhost:8080/web_JPetStore/showCategoryDetails?categoryId=' + param,
                success: function (data) {
                    var innerHTMLString = '';
                    for (let i = 0, length = data.length; i < length; i++) {
                        innerHTMLString += '<li>';
                        innerHTMLString += data[i].description;
                        innerHTMLString += '</li>';
                    }
                    $('#suspensionFrame').html(innerHTMLString);
                    $(par).mouseover(function (e) {
                        $('#suspensionFrame').css({
                            'left': (e.pageX + x + 10 + 'px'),
                            'top': (e.pageY + y - 40 + 'px')
                        }).show();
                    }).mousemove(function (e) {
                        $('#suspensionFrame').css({
                            'left': (e.pageX + x + 10 + 'px'),
                            'top': (e.pageY + y - 40 + 'px')
                        }).show();
                    }).mouseout(function () {
                        $('#suspensionFrame').hide();
                    });
                },
                error: function (errorMsg) {
                    console.log(errorMsg);
                }
            });
        }
        ;
    });
});